package calc.equations;

import java.util.Random;

public class BuildEquation {
	public BuildEquation(){
		
	}
	
	public Equation expandEquation(Equation equ, int equType, int expandNum){
		Random randomGenerator = new Random();
		if(expandNum == 0){
			return createEquation(equ, equType);
		}else{
			return expandEquation(createEquation(equ, randomGenerator.nextInt(3)), equType, expandNum-1);
		}
	}
	
	public Equation createEquation(Equation equ, int equType){
		if(equ == null){
			if(equType == 0){
				return new AdditionEquation();
			}
			if(equType == 1){
				return new SubtractionEquation();
			}
			if(equType == 2){
				return new MultiplicationEquation();
			}
		}else{
			if(equType == 0){
				return new AdditionEquation(equ);
			}
			if(equType == 1){
				return new SubtractionEquation(equ);
			}
			if(equType == 2){
				return new MultiplicationEquation(equ);
			}
		}
		return null;
	}
}
